/*
 * @(#)IndexAreaDVMRP.java     Robert Denda&Didier Gutacker
 *
 */

/** 
 *
 * @author 	Robert Denda&Didier Gutacker
 * @version     1.1, 05.09.1997
 * @see SimulationFrame
 * @see Simulation
 * @see Legende
 *
 */

import java.awt.*;

public class IndexAreaDVMRP extends Legende {

  public IndexAreaDVMRP( Simulation simulation, SimulationFrame frame ){
   super( simulation , frame );
   repaint();
  }

  public void paint( Graphics gc ) {
    this.gc = gc;
    fontMetrics = gc.getFontMetrics();
    int textHeight = fontMetrics.getAscent() + fontMetrics.getDescent() + 1;
    int y = textHeight-10, x = 10;
    
    Packet routingTableUpdatePacket = new Packet( true, Color.blue, "RoutingTableUpdate", null,0, 1 );
    routingTableUpdatePacket.increaseTravelPercentage( 1, 1 );
    routingTableUpdatePacket.paint( gc, x, y, x + 20, y );
    gc.drawString( ": " + simulation.getText().routingUpdatePacketText, x + 20, y + textHeight / 2 );
    y += textHeight + 5;
    
    Packet routingTableRequestPacket = new Packet( true, Color.orange, "RoutingTableRequest", null,0, 1 );
    routingTableRequestPacket.increaseTravelPercentage( 1, 1 );
    routingTableRequestPacket.paint( gc, x, y, x + 20, y );
    gc.drawString( ": " + simulation.getText().routingTableRequestPacketText, x + 20, y + textHeight / 2 );
    y += textHeight + 5;
    
    Packet multicastPacket = new Packet( true, Color.magenta, "Multicast Packet", null,0, 1 );
    multicastPacket.increaseTravelPercentage( 1, 1 );
    multicastPacket.paint( gc, x, y, x + 20, y );
    gc.drawString( ": " + simulation.getText().multicastPacketText, x + 20, y + textHeight / 2 );
    y += textHeight + 5;
    
    String s = simulation.getText().menuBar_editButton_simulationSpeedButtonText + ": ";
    
    int speed = frame.getAnimationSpeed();
    
    if ( speed == 0 ) {
      s += simulation.getText().menuBar_editButton_simulationSpeedButton_slowButtonText;
    } else if ( speed == 1 ) {
      s += simulation.getText().menuBar_editButton_simulationSpeedButton_normalButtonText;
    } else {
      s += simulation.getText().menuBar_editButton_simulationSpeedButton_fastButtonText;
    } // if
    gc.drawString( s, x, y + textHeight);
    
    y = textHeight-10;
    x += 40 + fontMetrics.stringWidth( simulation.getText().routingTableRequestPacketText);
    
    Packet pruningPacket = new Packet( true, Color.green, "Pruning Packet", null,0, 1 );
    pruningPacket.increaseTravelPercentage( 1, 1);
    pruningPacket.paint( gc, x, y, x + 20, y );
    gc.drawString( ": " + simulation.getText().pruningPacketText, x + 20, y + textHeight / 2 );
    y += textHeight + 5;
    
    Packet graftingPacket = new Packet( true, Color.red, "Grafting Packet", null,0, 1 );
    graftingPacket.increaseTravelPercentage( 1, 1 );
    graftingPacket.paint( gc, x, y, x + 20, y );
    gc.drawString( ": " + simulation.getText().graftingPacketText, x + 20, y + textHeight / 2 );
    
    y += textHeight + 5;
    
    Packet graftingAckPacket = new Packet( true, Color.black, "GraftingAck Packet", null,0, 1 );
    graftingAckPacket.increaseTravelPercentage( 1, 1 );
    graftingAckPacket.paint( gc, x, y, x + 20, y );
    gc.drawString( ": " + simulation.getText().graftingPacketAckText, x + 20, y + textHeight / 2 );
    
    y += textHeight + 5;
    
    if ( frame.demoRunning() ) {
      Color oldColor = gc.getColor();
      gc.setColor( Color.red );
      s = simulation.getText().simulationText + " " + simulation.getText().runningText;
      gc.drawString( s, x, y + textHeight );
      gc.setColor( oldColor );
    } else {
      gc.clearRect( x, y, x + 400, y + textHeight );
    } // if
  } // IndexAreaDVMRP.paint

} // IndexAreaDVMRP
